/** * 左边菜单 */
<template>
  <el-menu
    default-active="2"
    :collapse="collapsed"
    collapse-transition
    router
    :default-active="$route.path"
    unique-opened
    class="el-menu-vertical-demo"
    background-color="#090E1C"
    text-color="#fff"
    active-text-color="#E7D3B1"
  >
    <div class="logobox">
      <img class="logoimg" src="../assets/img/heima.png" alt="" />
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template v-slot:title>
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: [],
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    const studentOrAdmin = window.sessionStorage.getItem('useroradmin')
    console.log(studentOrAdmin)
    let res = null
    if(studentOrAdmin==='1'){
res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-cat-skuQuery',
              menuname: '首页',
              hasThird: 'N',
              url: '/welcomeadmin',
              menus: null,
            },
          ],
        },

        {
          menuid: 71,
          icon: 'li-icon-xitongguanli',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 73,
              icon: 'icon-news-manage',
              menuname: '查询学生信息',
              hasThird: 'N',
              url: '/select',
              menus: null,
            }, 
            {
              menuid: 74,
              icon: 'icon-news-manage',
              menuname: '查询测试记录',
              hasThird: 'N',
              url: '/selct',
              menus: null,
            },
            {
              menuid: 76,
              icon: 'icon-cs-manage',
              menuname: '占比图表',
              hasThird: 'N',
              url: '/view',
              menus: null,
            },
          ],
        },
      ],
      msg: 'success',
    }
    }else{
      res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-cat-skuQuery',
              menuname: '首页',
              hasThird: 'N',
              url: '/welcome',
              menus: null,
            },
          ],
        },

        {
          menuid: 71,
          icon: 'li-icon-xitongguanli',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 72,
              icon: 'icon-cus-manage',
              menuname: '开始测试',
              hasThird: 'N',
              url: '/test',
              menus: null,
            },
            
            {
              menuid: 75,
              icon: 'icon-cs-manage',
              menuname: '人格类型',
              hasThird: 'N',
              url: '/INTJ',
              menus: null,
            },
             {
              menuid: 76,
              icon: 'icon-cs-manage',
              menuname: '占比图表',
              hasThird: 'N',
              url: '/view',
              menus: null,
            },
           
          ],
        },
      ],
      msg: 'success',
    }
    }
   
    this.allmenu = res.data
  },
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #090E1C !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 20px;
  line-height: 20px;
  color: #9d9d9d;
  font-size: 10px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 100px;
}
</style>
